﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width" />
    <title>问题反馈交流</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet" />
    <script src="../Content/scripts/jquery-1.11.1.min.js"></script>
    <link href="../Content/styles/font-awesome.min.css" rel="stylesheet" />
    <link href="../Content/scripts/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <script src="../Content/scripts/plugins/jquery-ui/jquery-ui.min.js"></script>
    <link href="../Content/scripts/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <script src="../Content/scripts/bootstrap/bootstrap.min.js"></script>
    <link href="../Content/scripts/plugins/jqgrid/jqgrid.css" rel="stylesheet" />
    <link href="../Content/styles/learun-ui.css" rel="stylesheet" />
    <script src="../Content/scripts/plugins/jqgrid/grid.locale-cn.js"></script>
    <script src="../Content/scripts/plugins/jqgrid/jqgrid.min.js"></script>
    <script src="../Content/scripts/plugins/tree/tree.js"></script>
    <script src="../Content/scripts/plugins/validator/validator.js"></script>
    <script src="../Content/scripts/utils/learun-ui.js"></script>
    <script src="../Content/scripts/utils/learun-form.js"></script>
    <script src="ProblemJS.js"></script>

    <style type="text/css">
        body {
            margin: 10px;
            margin-bottom: 0px;
        }
    </style>
</head>
<body>
    <div class="titlePanel">
        <div class="title-search">
            <table>
                <tr>
                    <td style="padding-left: 5px;">
                        <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入留言人查询留言信息" style="width: 200px;" />
                    </td>
                    <td style="padding-left: 5px;">
                        <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
                    </td>
                </tr>
            </table>
        </div>
        <div class="toolbar">
            <div class="btn-group">
                <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增留言</a>
                <!--<a id="lr-answer" class="btn btn-default" onclick="btn_answer(event)"><i class="fa fa-pencil-square-o"></i>&nbsp;解答</a>-->
                <!--<a id="lr-delete" class="btn btn-default" onclick="btn_delete(event)"><i class="fa fa-trash-o"></i>&nbsp;删除</a>-->
            </div>
        </div>
    </div>
    <div class="titlePanel">
        我收到的留言
    </div>
    <div class="gridPanel">
        <table id="gridTable"></table>
        <!--<div id="gridPager"></div>-->
    </div>

    <div class="titlePanel">
        我发送的留言
    </div>
    <div class="gridPanel">
        <table id="gridTableSend"></table>
        <!--<div id="gridPagerSend"></div>-->
    </div>
    <script type="text/javascript">


        $(function () {
            //if (getCookie("CustomerID") == "") {
            //    $("#lr-add").css('display', 'none');
            //}
            //else {
            //    $("#lr-answer").css('display', 'none');
            //}
            $('#gridTable').setGridWidth(($('.gridPanel').width()));
            $("#gridTable").setGridHeight($(window).height() - 600);
            $('#gridTableSend').setGridWidth(($('.gridPanel').width()));
            $("#gridTableSend").setGridHeight($(window).height() - 600);
        })

        $(window).resize(function (e) {
            window.setTimeout(function () {
                $('#gridTable').setGridWidth(($('.gridPanel').width()));
                $("#gridTable").setGridHeight($(window).height() - 400);
                $('#gridTableSend').setGridWidth(($('.gridPanel').width()));
                $("#gridTableSend").setGridHeight($(window).height() - 400);
            }, 200);
            e.stopPropagation();
        });

        //加载表格
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable');
        $gridTable.jqGrid({
            postData: {
                Action: "GetProblemInfo",
                keyword: $("#txt_Keyword").val(),
                ToUserNo: getCookie("userno")
            },
            url: "./ProblemInfo.ashx",
            datatype: "json",
            height: $(window).height() - 200,
            autowidth: true,
            colModel: [
                { label: '主键', name: 'ID', hidden: true },
                { label: '留言人', name: 'FormUserNo', hidden: true },
                { label: '留言时间', name: 'MessageTime', index: 'MessageTime', width: 250, align: 'left' },
                //{ label: '厂商名称', name: 'CustomerName', index: 'CustomerName', width: 200, align: 'left' },
                { label: '留言人', name: 'FormUserName', index: 'FormUserName', width: 200, align: 'left' },
                //{ label: '设备台号', name: 'CustomerEqu', index: 'CustomerEqu', width: 100, align: 'left' },
                { label: '留言信息', name: 'MessageWords', index: 'MessageWords', width: 600, align: 'left' },
                {
                    label: '图片', name: 'ProblemImage', index: 'ProblemImage', width: 100, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue != "") {
                            return '<span  class=\"label label-success\" style=\"cursor: pointer;margin-left:5px;\" onclick="btn_ImgLook(\'' + rowObject[0] + '\')">查看</span>';
                        } else {
                            return '';
                        }

                    }
                },
                {
                    label: '视频', name: 'ProblemVideo', index: 'ProblemVideo', width: 100, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue != "") {
                            return '<span  class=\"label label-success\" style=\"cursor: pointer;margin-left:5px;\" onclick="btn_VideoLook(\'' + rowObject[0] + '\')">查看</span>';
                        } else {
                            return '';
                        }

                    }
                },
                {
                    label: '操作', name: 'RepeateState', index: 'RepeateState', width: 100, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue != 1) {
                            return '<span  class=\"label label-warning\" style=\"cursor: pointer;margin-left:5px;\" onclick="btn_Repeate(\'' + rowObject[0] + '\',\'' + rowObject[1] + '\')">回复</span>';
                        }
                        else {
                            return '<span  class=\"label label-success\" style=\"margin-left:5px;\" >已回复</span>';
                        }
                    }
                },
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            sortname: 'ID',
            sortable: true,
            pager: "#gridPager",
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });


        //加载表格
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTableSend');
        $gridTable.jqGrid({
            postData: {
                Action: "GetProblemInfoSend",
                keyword: $("#txt_Keyword").val(),
                ToUserNo: getCookie("userno")
            },
            url: "./ProblemInfo.ashx",
            datatype: "json",
            height: $(window).height() - 200,
            autowidth: true,
            colModel: [
                { label: '主键', name: 'ID', hidden: true },
                { label: '收件人', name: 'ToUserNo', index: 'MessageTime', width: 250, align: 'left' },
                { label: '发送时间', name: 'MessageTime', index: 'MessageTime', width: 250, align: 'left' },
                //{ label: '厂商名称', name: 'CustomerName', index: 'CustomerName', width: 200, align: 'left' },
                //{ label: '留言人', name: 'FormUserName', index: 'FormUserName', width: 200, align: 'left' },
                //{ label: '设备台号', name: 'CustomerEqu', index: 'CustomerEqu', width: 100, align: 'left' },
                { label: '信息内容', name: 'MessageWords', index: 'MessageWords', width: 600, align: 'left' },
                {
                    label: '图片', name: 'ProblemImage', index: 'ProblemImage', width: 100, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue != "") {
                            return '<span  class=\"label label-success\" style=\"cursor: pointer;margin-left:5px;\" onclick="btn_ImgLook(\'' + rowObject[0] + '\')">查看</span>';
                        } else {
                            return '';
                        }

                    }
                },
                {
                    label: '视频', name: 'ProblemVideo', index: 'ProblemVideo', width: 100, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue != "") {
                            return '<span  class=\"label label-success\" style=\"cursor: pointer;margin-left:5px;\" onclick="btn_VideoLook(\'' + rowObject[0] + '\')">查看</span>';
                        } else {
                            return '';
                        }

                    }
                },
                {
                    label: '操作', name: 'RepeateState', index: 'RepeateState', width: 100, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue != 1) {
                            return '<span  class=\"label label-danger\" style=\"margin-left:5px;\" >未回复</span>';
                        }
                        else {
                            return '<span  class=\"label label-success\" style=\"margin-left:5px;\" >已回复</span>';
                        }
                    }
                },
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            sortname: 'ID',
            sortable: true,
            pager: "#gridPager",
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });


        //查询事件
        $("#btn_Search").click(function () {

            $gridTable.jqGrid('setGridParam', {
                postData: {
                    Action: "GetProblemInfo",
                    keyword: $("#txt_Keyword").val(),
                    CustomerName: getCookie("CustomerName")
                },
            }).trigger('reloadGrid');

        });

        //查询回车
        $('#txt_Keyword').bind('keypress', function (event) {
            if (event.keyCode == "13") {
                $('#btn_Search').trigger("click");
            }
        });


        //新增问题信息
        function btn_add(event) {

            dialogOpen({
                id: "Form",
                title: '新增问题',
                url: '../ProblemInfo/ProblemInfoAdd.html',
                width: "800px",
                height: "600px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick($('#gridTable'));
                }
            });
        }

        //图片查看
        function btn_ImgLook(keyword) {

            if (keyword == undefined) {
                keyword = $("#gridTable").jqGridRowValue("ID");
            }

            dialogOpen({
                id: "Form",
                title: '查看图片',
                url: '../ProblemInfo/ProblemImg.html?&ID=' + keyword,
                width: "800px",
                height: "600px",
                btn: null
            });

        }

        // 视频查看
        function btn_VideoLook(keyword) {
            if (keyword == undefined) {
                keyword = $("#gridTable").jqGridRowValue("ID");
            }

            dialogOpen({
                id: "Form",
                title: '查看视频',
                url: '../ProblemInfo/ProblemVideo.html?&ID=' + keyword,
                width: "800px",
                height: "600px",
                btn: null
            });

        }


        // 问题删除
        function btn_delete(event) {

            var keyValue = $("#gridTable").jqGridRowValue("ID");
            if (keyValue) {
                dialogConfirm("注：您确定要删除吗？该操作将无法恢复", function (r) {
                    if (r) {
                        Loading(true, "正在删除数据...");

                        window.setTimeout(function () {
                            $.probleminfojs.deleteProblemInfo(keyValue, $('#gridTable'));
                        }, 500);
                    }
                });
            }
        }

        // 留言回复
        function btn_Repeate(keyword, keyvalue) {
            if (keyword == undefined) {
                keyword = $("#gridTable").jqGridRowValue("ID");
                keyvalue = $("#gridTable").jqGridRowValue("FormUserNo");
            }

            dialogOpen({
                id: "Form",
                title: '留言回复',
                url: '../ProblemInfo/MessageRepeate.html?&ID=' + keyword + '&FormUserNo=' + keyvalue,
                width: "800px",
                height: "600px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick($('#gridTable'));
                }
            });
        }
        //读取cookie
        function getCookie(name) {
            var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
            if (arr != null) return decodeURI(arr[2]); return null;
        };

    </script>
</body>
</html>



